﻿<!Doctype html>
<html xmlns="http://www.w3.org/1999/html">
<!---------------------------------------------------------
Auther:：Fin;  Version：Autotestplat-V2.7
----------------------------------------------------------->
<head>
    <meta charset="UTF-8">
    <title> 测试报告详情 </title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/style.css" type="text/css">
    <link rel="stylesheet" href="/static/css/fileinput.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/select2.min.css" />
    <link href="/static/css/navbar.css" rel="stylesheet" type="text/css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script src="/static/js/select2.min.js"></script>
    <script src="/static/js/select2.full.min.js"></script>
    <script src="/static/js/public.js"></script>
    <script type="text/javascript" charset="gbk" src="/static/js/fileinput.min.js"></script>
    <script>
    window.onload = function() {
        if(loginVerify() == 200){
        }
        var selectElement = document.getElementById('select-option');
        var options = selectElement.options;
        for (var i = 0; i < options.length; i++) {
            if (options[i].text === "{{ product_name }}") {
                options[i].style.display = 'none';
                break;
            }
        }
        const downloadLink = document.getElementById('download-link');
        downloadLink.addEventListener('click', function(event) {
        event.preventDefault();
        const bodyContent = document.getElementById('outterDiv').innerHTML;
        const elementsToHide = document.querySelectorAll('#table_api_info');
        const api_count = elementsToHide.length;
        let filteredContent = bodyContent;
        for (var i = 0; i < api_count; i++) {
            var element = elementsToHide[i];
            var regex = new RegExp(`${element.innerHTML}`, 'g');
            filteredContent = filteredContent.replace(regex, '');
        }
        const elementsToHide2 = document.getElementById('table_title').innerHTML;
        var regex2 = new RegExp(`${elementsToHide2}`, 'g');
        filteredContent = filteredContent.replace(regex2, '');
        const buttonId = 'search_button';
        const parser = new DOMParser();
        const doc = parser.parseFromString(filteredContent, 'text/html');
        const button = doc.getElementById(buttonId);
        if (button) {
            button.parentNode.removeChild(button);
        }
        const newFilteredContent = doc.documentElement.innerHTML;
        const blob = new Blob([newFilteredContent], {type: 'text/html'});
        const url = URL.createObjectURL(blob);
        const downloadLink = document.createElement('a');
        downloadLink.href = url;
        downloadLink.download = 'apiTestReport-' + {{ report_id }} + '.html';
        document.body.appendChild(downloadLink);
        downloadLink.click();
        document.body.removeChild(downloadLink);
        });
    };
    </script>
</head>
<body>
    <div class="row" >
        <div class="col-sm">
            <ul class="nav nav-pills nav-pills-success nav-pills-square nav-light bg-white pa-15 fixed-top">
                <li class="nav-item">
                    <a href={% url 'product' %} class="nav-link"> 产品管理 </a>
                </li>
                <li class="nav-item">
                    <a href={% url 'apitestcase' %} class="nav-link"> 接口用例 </a>
                </li>
                <li class="nav-item">
                    <a href={% url 'apitestplan' %} class="nav-link"> 测试计划 </a>
                </li>
                <li class="nav-item">
                    <a href={% url 'apireport' %} class="nav-link active"> 测试报告 </a>
                </li>
                <li class="nav-item">
                    <a href={% url 'apiperformance' %} class="nav-link"> 性能测试 </a>
                </li>
                <li class="nav-item dropdown" id="uiDropdown">
                <a id="uitest" class="nav-link"> UI测试 </a>
                <ul class="dropdown-menu" id="uiDropdownMenu">
                    <li><a href={% url 'apptestcase' %} class="nav-link"> AppUI测试 </a></li>
                    <li><a href={% url 'webtestcase' %} class="nav-link"> WebUI测试 </a></li>
                </ul>
                </li>
                <li class="nav-item">
                    <a href={% url 'parasettings' %} class="nav-link"> 系统设置 </a>
                </li>
                <li class="nav-item">
                    <a href={% url 'user' %} class="nav-link "> 用户管理 </a>
                </li>
                <li class="nav-item" id="cur_product" style="margin-left: 200px">
                    <select id="select-option" name="setInput"  onchange="saveOption()">
                        <option>{{ product_name }}</option>
                        {% for product in product_alls %}
                        <option>
                        {% if product.product_name == product_name %}
                            {{ product.product_name }} ✓
                        {% else %}
                            {{ product.product_name }}
                       {% endif %}
                       </option>
                       {% endfor %}
                    </select>
                </li>
                <li class="nav-item dropdown-user" id="navUser">
                    <a href="#" class="nav-link" id="userName" style="font-size: 13px"></a>
                <ul class="dropdown-menu" id="userDropdownMenu">
                    <li> <a href="https://docs.qq.com/doc/DSVNlZ0xoUWpHYlpx?u=2f0ea49eb4e247f5b3c604c3d58ef026" class="nav-link" style="font-size: 13px" target="_black">使用手册</a></li>
                    <li><a class="nav-link" onclick="logout()" style="font-size: 12px"> 退出 </a></li>
                </ul>
                </li>
            </ul>
        </div>
    </div>

    <div id="outterDiv" class="hk-wrapper screenHeight">
        <div class="container" style="padding: 0px 20px; max-width: 1800px;">
        <section class="hk-sec-wrapper">
        <div class="row">
        <div class="col-md-12">
            <div class="panel panel-primary">
                <div class="panel-body">
                <h1 style="font-size: 24px;color:green;text-align:center;">接口自动化测试报告</h1><br>
                <ul class="headline" style="margin-left: -20px">
                    <li>测试报告ID：<span style="font-size: 16px">{{ report_id }} </span></li>
                </ul>
                <ul class="headline" style="margin-left: -20px">
                    <br>
                    <li>产品/项目：<span style="font-size: 16px">{{ product_name }} </span></li>
                </ul>
                <ul class="headline" style="margin-left: -20px">
                    <br>
                    <li>测试计划：<span style="font-size: 16px">{{ testplan_name }} </span></li>
                </ul>
                <ul class="headline" style="margin-left: -20px;">
                    <br>
                    <li>用例总数： <span id="testcase_all_count" style="font-size: 16px"> {{ testcase_all_count }}</span>
                    &nbsp;&nbsp;通过： <span style="font-size: 16px;color: blue"> {{ testcase_pass_count }}</span>
                    &nbsp;&nbsp;不通过：<span style="font-size: 16px;color: red"> {{ testcase_fail_count }}</span>
                   &nbsp;&nbsp;未执行： <span style="font-size: 16px;color: lightgrey"> {{ testcase_norun_count }}</span>
                    &nbsp;&nbsp;成功率： <span style="font-size: 16px"> {{ testcase_pass_pers }}</span></li>
                </ul>
                <ul class="headline" style="margin-left: -20px">
                    <br>
                    <li>测试时间： <span style="font-size: 14px;font-weight: normal"> {{ testplan_time }}</span></li>
                </ul>
                    <br>
                    <div class="table-responsive">
                        <table id="table_title" class="table table-bordered">
                            <thead>
                                <tr>
                                    <th style="text-align: left;width: 30px">#</th>
                                    <th style="text-align: left;width: 320px;">接口名称</th>
                                    <th style="text-align: left;width: 420px;">接口URL</th>
                                    <th style="text-align: left;width: 100px;">结果</th>
                                    <th style="text-align: left;width: 150px;">响应时间</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                        <div style="margin-top: -22px">
                            {% for rec in test_result %}
                                {% if rec.result == "0" %}
                                <div class="panel-group" id="accordion">
                                    <div class="panel panel-default">
                                        <div class="panel-heading" style="background-color: white;">
                                            <h4 id="table_api_info" class="panel-title" style="font-size: 14px">
                                                <a data-toggle="collapse" data-parent="#accordion" href="#collapse{{ forloop.counter }}">
                                                    <div class="row">
                                                        <div class="col-md-1" style="text-align: left;">{{ forloop.counter }}</div>
                                                        <div class="col-md-1" style="display: none;">{{ rec.suit_interface_id }}</div>
                                                        <div id="table_interface_name" class="col-md-2" style="white-space: nowrap;overflow: hidden;text-align: left;margin-left: -70px;width: 320px">{{ rec.interface_name }}</div>
                                                        <div id="table_url" class="col-md-4" style="white-space: nowrap;overflow: hidden;text-align: left;margin-left: 40px;width: 320px">{{ rec.url | cut:"http://127.0.0.1" }}</div>
                                                        <div id="table_result" class="col-md-2" style="overflow: hidden;text-align: left;margin-left: 160px;width: 115px">
                                                            {% if rec.result == "0" %}
                                                                <span style="color: green;"> pass</span>
                                                            {% elif rec.result == "1" %}
                                                                <span style="color: red;"> fail</span>
                                                            {% else %}
                                                                <span> no_run</span>
                                                            {% endif %}
                                                        </div>
                                                        <div id="table_response_time" class="col-md-1" style="white-space: nowrap;overflow: hidden;text-align: left;">{{ rec.response_time }}</div>
                                                    </div>
                                                </a>
                                            </h4>
                                        </div>
                                        <div id="collapse{{ forloop.counter }}" class="panel-collapse collapse">
                                            <div class="panel-body" style="background-color: #eaebee">
                                                <div class="row" >
                                                    <div class="col-md-5">
                                                        <div class="form-group">
                                                            <span style="font-weight: bold;text-align: left;">{{ forloop.counter }}、接口名称</span>：{{ rec.interface_name }}
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">接口URL</span>：<span style="word-break:break-all;">{{ rec.url }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">请求参数</span>：<span style="word-break:break-all;">{{ rec.body }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">请求方式</span>：{{ rec.mode }}
                                                        </div>
                                                    </div>
                                                    <div class="col-md-7">
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">断言</span>：{{ rec.assert_keywords_old }}
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold;">响应数据</span>：<span style="word-break:break-all;">{{ rec.response }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold;">响应时间</span>：<span style="word-break:break-all;">{{ rec.response_time }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">测试结果</span>：
                                                            {% if rec.result == "0" %}
                                                                <span style="color: green"> pass</span>
                                                            {% elif rec.result == "1" %}
                                                                <span style="color: red"> fail</span>
                                                            {% else %}
                                                                <span> no_run</span>
                                                            {% endif %}
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    </div>
                                    {% else %}
                                {% endif %}
                            {% endfor %}
                            {% for rec in test_result %}
                                {% if rec.result == "1" %}
                                <div class="panel-group" id="accordion">
                                    <div class="panel panel-default">
                                        <div class="panel-heading" style="background-color: white;">
                                            <h4 id="table_api_info" class="panel-title" style="font-size: 14px">
                                                <a data-toggle="collapse" data-parent="#accordion" href="#collapse{{ forloop.counter }}">
                                                    <div class="row">
                                                        <div class="col-md-1" style="text-align: left;">{{ forloop.counter }}</div>
                                                        <div class="col-md-1" style="display: none">{{ rec.suit_interface_id }}</div>
                                                        <div class="col-md-2" style="white-space: nowrap;overflow: hidden;text-align: left;margin-left: -70px;width: 320px">{{ rec.interface_name }}</div>
                                                        <div id="table_url" class="col-md-4" style="white-space: nowrap;overflow: hidden;text-align: left;margin-left: 40px;width: 320px">{{ rec.url | cut:"http://127.0.0.1" }}</div>
                                                        <div class="col-md-2" style="overflow: hidden;text-align: left;margin-left: 160px;width: 115px">
                                                            {% if rec.result == "0" %}
                                                                <span style="color: green"> pass</span>
                                                            {% elif rec.result == "1" %}
                                                                <span style="color: red"> fail</span>
                                                            {% else %}
                                                                <span> no_run</span>
                                                            {% endif %}
                                                        </div>
                                                        <div id="table_response_time"  class="col-md-1" style="white-space: nowrap;overflow: hidden;text-align: left;">{{ rec.response_time }}</div>
                                                    </div>
                                                </a>
                                            </h4>
                                        </div>
                                        <div id="collapse{{ forloop.counter }}" class="panel-collapse collapse">
                                            <div class="panel-body" style="background-color: #eaebee">
                                                <div class="row" >
                                                    <div class="col-md-5">
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">接口名称</span>：{{ rec.interface_name }}
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">接口URL</span>：<span style="word-break:break-all;">{{ rec.url }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">请求参数</span>：<span style="word-break:break-all;">{{ rec.body }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">请求方式</span>：{{ rec.mode }}
                                                        </div>
                                                    </div>
                                                    <div class="col-md-7">
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">断言</span>：{{ rec.assert_keywords_old }}
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold;">响应数据</span>：<span style="word-break:break-all;">{{ rec.response }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold;">响应时间</span>：<span style="word-break:break-all;">{{ rec.response_time }}</span>
                                                        </div>
                                                        <div class="form-group">
                                                            <span style="font-weight: bold">测试结果</span>：
                                                            {% if rec.result == "0" %}
                                                                <span style="color: green"> pass</span>
                                                            {% elif rec.result == "1" %}
                                                                <span style="color: red"> fail</span>
                                                            {% else %}
                                                                <span> no_run</span>
                                                            {% endif %}
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                {% else %}
                                {% endif %}
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div class="form-group">
            <div class="row">
            <div class="col-md-9">
              <button id="search_button" class="btn btn-primary" style="margin-left: 60%;width: 57px;height: 34px;font-size: 14px"  type="submit" onclick="goBack()">返回</button>
            </div>
            <div class="col-md-1">
                <a href="" class="btn btn-primary" style="margin-left: -360%;width: 57px;height: 34px;font-size: 14px" id="download-link">下载</a>
            </div>
            </div>
        </div>
        </section>
         </div>
    </div>

</body>
</html>
